package com.cefetmg.mmc.mrcpsp.utils;



/**
 * @author mrcosta
 *
 */
public final class UrlUtils {
	
	private static UrlUtils instance;
	
	private static UrlUtils createNewInstance() {
		instance = new UrlUtils();
		return instance;
	}
	
	public static UrlUtils getInstance() {
		if (instance == null) {
			createNewInstance();
		}
		return instance;
	}
	
	public String getUrlForInstanceFile() {
		return PropertyConstants.INSTANCE_BASE_URL + 
			   PropertyManager.getInstance().getProperty(PropertyConstants.INSTANCES_FOLDER);
	}
	
	public Integer getStartLineJobs() {
		return Integer.parseInt(PropertyManager.getInstance().getProperty(PropertyConstants.START_LINE_JOBS));
	}
	
	public Integer getStartLineModes() {
		return Integer.parseInt(PropertyManager.getInstance().getProperty(PropertyConstants.START_LINE_MODES));
	}
	
	public Integer getStartLineResourceAvailabilities() {
		return Integer.parseInt(PropertyManager.getInstance().getProperty(PropertyConstants.START_LINE_RESOURCES_AVAILABILITIES));
	}
	
	public Integer getRCLSize() {
		return Integer.parseInt(PropertyManager.getInstance().getProperty(PropertyConstants.RCL_SIZE));
	}
	
	public String getJobsMode() {
		return PropertyManager.getInstance().getProperty(PropertyConstants.MODE_JOBS);
	}
	
	public String getJobPriorityRule() {
		return PropertyManager.getInstance().getProperty(PropertyConstants.JOB_PRIORITY_RULE);
	}
	
	public String getExecutionType() {
		return PropertyManager.getInstance().getProperty(PropertyConstants.EXECUTION_TYPE);
	}
	
	public String getExecutionTimes() {
		return PropertyManager.getInstance().getProperty(PropertyConstants.EXECUTION_TIMES);
	}
	
	public String getBooleanThread() {
		return PropertyManager.getInstance().getProperty(PropertyConstants.HAS_THREAD);
	}
	
	public String getUrlForResultsFileToOneInstance(String fileName) {
		String pathFolder = PropertyConstants.RESULTS_PATH;
		String nameFile = fileName + "_results.txt";
		
		return FileUtils.createDirectory(pathFolder) + "/" + nameFile;
	}
	
	public String getUrlForInstance() {
		return PropertyConstants.INSTANCE_BASE_URL + 
			   PropertyManager.getInstance().getProperty(PropertyConstants.INSTANCES_FOLDER);
	}
	
	public String getUrlForResultsFileToAllInstances() {
		String pathFolder = PropertyConstants.RESULTS_PATH;
		String nameFile = "results.txt";
		
		return FileUtils.createDirectory(pathFolder) + "/" + nameFile;
	}

}
